//
//  StockInfoViewModel.m
//  HeXun
//
//  Created by 8003 on 15/11/24.
//  Copyright © 2015年 LGC. All rights reserved.
//

#import "StockInfoViewModel.h"

@implementation StockInfoViewModel


- (void)drawLine:(NSArray *)PointArr
{
    //view是曲线的背景view
    UIView* view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 300, 300)];
    view.backgroundColor = [UIColor whiteColor];
    [self addSubview:view];
    
    //第一、UIBezierPath绘制线段
    UIBezierPath *path = [UIBezierPath bezierPath];
    
    //点
    NSMutableArray* tempArr = [NSMutableArray new];
    for (NSValue* value in PointArr)
    {
        [tempArr addObject:value];
    }
    NSArray *arr = [NSArray arrayWithArray:tempArr];
    NSIndexSet *set = [NSIndexSet indexSetWithIndexesInRange:NSMakeRange(0, arr.count)];
    
    [arr enumerateObjectsAtIndexes:set options:0 usingBlock:^(NSValue *pointValue, NSUInteger idx, BOOL *stop){
        
        CGPoint point = [pointValue CGPointValue];
        [path addLineToPoint:point];
        CGRect rect;
        rect.origin.x = point.x ;
        rect.origin.y = point.y ;
        rect.size.width = 1;
        rect.size.height = 1;
        UIBezierPath *arc= [UIBezierPath bezierPathWithOvalInRect:rect];
        [path appendPath:arc];
        
    }];
    
    CAShapeLayer *lineLayer = [CAShapeLayer layer];
    lineLayer.frame = CGRectMake(0, 150, 320, 400);
    lineLayer.fillColor = [UIColor redColor].CGColor;
    lineLayer.path = path.CGPath;
    lineLayer.strokeColor = [UIColor redColor].CGColor;
    [view.layer addSublayer:lineLayer];
    
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, 100,800, 800)];
    view1.backgroundColor = [UIColor whiteColor];
    [self addSubview:view1];
    
    [UIView animateWithDuration:5 animations:^{
        view1.frame = CGRectMake(800, 100, 800, 800);
    }];

}
@end
